import { Factory, Faker } from "@mikro-orm/seeder";
import * as dayjs from "dayjs";
import { randomInt } from "crypto";
import { JobProjectJobs } from "../entities/JobProjectJobs";
import * as _ from 'lodash'
import { title } from "./TitleGenerater";

export class JobFactory extends Factory<JobProjectJobs> {
  model = JobProjectJobs;
  
  definition(faker: Faker): Partial<JobProjectJobs> {
    faker.setLocale('zh_CN')

    let startTime = randomInt(0,1) ? (dayjs('2022-02-22T06:00:00')).add(randomInt(0,4),'hours').add(randomInt(0,1)?0:30,'minutes')
    : dayjs('2022-02-22T12:00:00').add(randomInt(0,4),'hours').add(randomInt(0,1)?0:30);
   
    
    let startTimeText = startTime.format('HH:mm');

    let endTime = startTime.add(randomInt(5,10),'hours').add(randomInt(0,1)?0:30,'minutes');

    let endTimeText = endTime.format('HH:mm');

    return {
      name : _.shuffle([
          '咨客',
          '派单员',
          '调查问卷',
          '中餐厅服务员',
          '西餐厅服务员',
          '电CALL',
          '举牌',
          '充场',
      ])[0],
      settleType :  _.shuffle([
        '日结','月结','季结' 
      ])[0],
      priceType :_.shuffle([
          '小时','天' ,'周' ,'月'
      ])[0],
      price : 16,
      num: 8,
      startTime :  startTimeText,
      endTime : endTimeText,
      createdAt: new Date(),
      updatedAt: new Date(),
    };
  }
} 